<%@ Page Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeBehind="EditProfile.aspx.cs" Inherits="MusicmanWeb.USER.EditProfile" Title="Musicman Levi9 | Edit profile" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server">
<script type="text/javascript" language="javascript">

    function toggleEditPassword(cbObj)
    {
        var state = cbObj.checked;
        var passwordObj = document.getElementById('<%= this.Repeater1.Controls[1].FindControl("OldPassword").ClientID %>');
        var newPasswordObj = document.getElementById('<%= this.Repeater1.Controls[1].FindControl("Newpassword").ClientID %>');
        var passwordRetypeObj = document.getElementById('<%= this.Repeater1.Controls[1].FindControl("Newpassword2").ClientID %>');
        
        passwordObj.disabled = !state;
        newPasswordObj.disabled = !state;
        passwordRetypeObj.disabled = !state;
    }

</script>
<div class="shim column"></div>
<div class="page" id="register">
    <div id="sidebar">
    <h5>User stats</h5>
    
    <asp:Repeater ID="Repeater2" runat="server" DataSourceID="ObjectDataSource2">
    <HeaderTemplate>
        <table>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
      <td>Total logs web</td>
      <td style="text-align:right;"><%# Eval("NumLogsWeb")%></td>
    </tr>
    <tr>
      <td>Total logs client</td>
      <td style="text-align:right;"><%# Eval("NumLogsClient") %></td>
    </tr>
    <tr>
      <td>Total logs</td>
      <td style="text-align:right;"><%# Eval("TotalLogs")%></td>
    </tr>
    <tr>
      <td>Total files</td>
      <td style="text-align:right;"><%# Eval("TotalFiles")%></td>
    </tr>
    <tr>
      <td>Total traffic</td>
      <td style="text-align:right;"><%# Eval("TotalLengthMB") %></td>
    </tr>
    
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
    </asp:Repeater>

    </div>
    <div id="content">
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">
    <HeaderTemplate>
        <table>
    </HeaderTemplate>
    <ItemTemplate>
        <asp:HiddenField ID="PersonID" runat="server" Value='<%# Eval("PersonID") %>' />
        <tr>
            <td>
                Emailaddress:
            </td>
            <td align="Left">
                <asp:TextBox ID="EmailaddressTextBox" ReadOnly="true" runat="server" Text='<%# Bind("Emailaddress") %>'></asp:TextBox>
            </td>
        </tr>    
        <tr>
            <td>
                Firstname:
            </td>
            <td align="Right">
                <asp:TextBox ID="Firstname" runat="server" Text='<%# Bind("Firstname") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                    ControlToValidate="Firstname"
                    ValidationGroup="Editing">*</asp:RequiredFieldValidator>        
            </td>
        </tr>     
        <tr>
            <td>
                Lastname:
            </td>
            <td align="Right">
                <asp:TextBox ID="Lastname" runat="server" Text='<%# Bind("Lastname") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
                    ControlToValidate="Lastname"
                    ValidationGroup="Editing">*</asp:RequiredFieldValidator>        
            </td>
        </tr>   
        <tr>
            <td>
                MailRequest:
            </td>
            <td>
                <asp:CheckBox ID="MailRequestCheckBox" runat="server" Checked='<%# Bind("MailRequest") %>' />
            </td>
        </tr>
        <tr>
            <td>
                Change password:
            </td>
            <td>
			<% if (((TextBox)this.Repeater1.Controls[1].FindControl("OldPassword")).Enabled)
               { %> 
                <input type="checkbox" id="Checkbox1" name="changePasswordCb" onclick="toggleEditPassword(this);" checked="checked"/>
            <% } else { %> 
                <input type="checkbox" id="Checkbox2" name="changePasswordCb" onclick="toggleEditPassword(this);" />
            <% } %>            
                <%--<input type="checkbox" id="changePasswordCb" name="changePasswordCb" onclick="toggleEditPassword(this);" />--%>
            </td>
        </tr>
        <tr>
            <td>
                Old password:
            </td>
            <td align="Right">
                <asp:TextBox ID="OldPassword" Enabled="false" CausesValidation="true" runat="server" TextMode="password" ValidationGroup="Editing"/>
            </td>
        </tr>
        <tr>
            <td>
                New password:
            </td>
            <td align="Right">
                <asp:TextBox ID="Newpassword" runat="server" Enabled="false" TextMode="password"/>
            </td>
        </tr>   
        <tr>
            <td>
                Retype password:
            </td>
            <td align="Right">
                <asp:TextBox ID="Newpassword2" runat="server" Enabled="false" TextMode="password"/>
            </td>
        </tr> 
        <tr>
        <td colspan="2">

        </td>
        </tr>
        <tr>
        <td colspan="2">
            <asp:Label ID="ValidationMessage" runat="server" Visible="false" />
        </td>
        </tr>
        <tr>
        <td colspan="2">
            <asp:LinkButton ID="Update" runat="server"
            CausesValidation="true"
            ValidationGroup="Editing" 
            OnCommand="Update_Button">Update</asp:LinkButton>
            </td>
        </tr>
        
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
    </asp:Repeater>
    </div>
    </div>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" ConvertNullToDBNull="True" DataObjectTypeName="Musicman.Entities.User" 
                SelectMethod="GetUserInfo" 
                TypeName="Musicman.Business.DataManager" >
            <SelectParameters>
                <asp:SessionParameter Name="userID" SessionField="UserID" Type="Int64" />
            </SelectParameters>
        </asp:ObjectDataSource>

        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" ConvertNullToDBNull="True" DataObjectTypeName="Musicman.Entities.User" 
                SelectMethod="GetUserActivity" 
                TypeName="Musicman.Business.DataManager" >
            <SelectParameters>
                <asp:SessionParameter Name="personID" SessionField="UserID" Type="Int64" />
            </SelectParameters>
        </asp:ObjectDataSource>
        
</asp:Content>
